package NewCoder;

public class BM17 {
    public int search (int[] nums, int target) {
        // write code here
        if(nums.length==0) return -1;
        int l=0;
        int r=nums.length-1;
        while(l<=r){
            int mid=(r-l)/2+l;
            if(nums[mid]==target) return mid;
            if(nums[mid]<target){
                l=mid+1;
            }else {
                r=mid-1;
            }
        }
        return -1;
    }
}
